﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using DAL.Ad;
using Base;
public partial class admin : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckRights("Basic", "B1");
        btn_decided.Attributes.Add("onclick", "return  check();");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        bool imgW = GetRequest.isNum(TxB_Width.Text.Trim());

        if (!imgW)
        {
            lblMessage.Visible = true;
            lblMessage.InnerHtml = "图片的宽度必须是数字！";
            return;
        }
        else
            lblMessage.Visible = false;
        bool imgH = GetRequest.isNum(TxB_Length.Text.Trim());
        if (!imgH)
        {
            lblMessage.Visible = true;
            lblMessage.InnerHtml = "图片的高度必须是数字！";
            return;
        }
        else
            lblMessage.Visible = false;
        bool strMark = GetRequest.isProce(TxB_mark.Text.Trim());
        if (!strMark)
        {
            lblMessage.Visible = true;
            lblMessage.InnerHtml = "价格必须是数字,如：100.00";
            return;
        }
        else
            lblMessage.Visible = false;
        Model.Ad.AdItiem ad = new Model.Ad.AdItiem();
        ad.Name = this.TxB_name.Text.Trim();
        ad.Type = this.DDL_Adtype.SelectedValue.Trim();
        ad.Page = this.DDL_Place.SelectedValue.Trim();
        ad.IamgeAdress = ""; //this.TxB_ImageAdrees.Text.ToString().Trim();
        ad.AdWidth = int.Parse(TxB_Width.Text.Trim());
        ad.AdHeight = int.Parse(TxB_Length.Text.Trim());
        ad.Adrees = ""; //this.TxB_adrees.Text.Trim();
        ad.Mark =decimal.Parse(TxB_mark.Text.Trim());
        AdPlaceManage ap = new AdPlaceManage();
        ap.AdAdPlace(ad);
        
        Response.Write("<script>alert('添加成功');location.href='AdPlaceList.aspx';</script>");
        }
        #region 上传事件处理
    //protected void btn_upload_Click(object sender, EventArgs e)
    // {
    //     Base.Core.WebConfig web = new Base.Core.WebConfig();
    //     string imgsFolder = web.ImgFolder;
    //     string datatime = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
    //     if (this.FileUploadAdrees.HasFile)
    //     {
    //         string fileName = this.FileUploadAdrees.FileName;
    //         string fileExition = System.IO.Path.GetExtension(fileName).ToLower();
    //         string de = "|.gif|.png|.jpeg|.jpg";
    //         string path = HttpContext.Current.Server.MapPath("~/" + imgsFolder);
    //         if (!System.IO.Directory.Exists(path))
    //         {
    //             System.IO.Directory.CreateDirectory(path);
    //         }
    //         if (fileName == "")
    //         {
    //             Response.Write("<script>alert('请选择上传的图片');</script>");
    //             return;
    //         }
    //         if (de.IndexOf(fileExition) > 0)
    //         {
    //             string NewFileName ="/"+datatime + fileExition;
    //             this.FileUploadAdrees.PostedFile.SaveAs(path + NewFileName);
    //             this.TxB_ImageAdrees.Text = Base.BasePage.Config.WebURL + imgsFolder+NewFileName;
    //         }
    //         else
    //         {
    //             Response.Write("<script>alert('上传图片格式错误');</script>");
    //         }

    //     }
    //}
        #endregion
}
